const { Schema, model } = require('mongoose');

const foodsSchema = new Schema({
    name: String,
    images: String,
    views: [{
        type: Schema.Types.ObjectId,
        ref: 'usersModel'
    }]
    ,
    time: String,
    material: [{
        name: String,
        unit: String
    }],
    step: [{
        images: String,
        practice: String
    }],
    needVip: {
        type: Boolean,
        default: true
    },
    tips: String,
    classifysId: {
        type: Schema.Types.ObjectId,
        ref: 'classifysModel'
    },
    browse: [{
        usersId: Schema.Types.ObjectId,
    }],
    comment: [{
        usersId: Schema.Types.ObjectId,
        content: String,
        code: {
            type: Number,
            default: 0
        }
    }],
    collect: [{
        type: Schema.Types.ObjectId,
        ref: 'usersModel'
    }]
}, { versionKey: false });

const foodsModel = model('foodsModel', foodsSchema, 'foods');

module.exports.foodsModel = foodsModel;